leetcode 977